<link rel="stylesheet" type="text/css" href="<?=ROOT_PATH?>/html/styles/shop/shop_buy.css" media="screen" />
<h1 class="ThisPosition">Cart &amp; Checkout</h1>
<ol class="StepTiImg">
  <li class="mar48"></li>
  <li>1.Cart</li>
  <li class="li2"></li>
  <li>2.Shipping Address</li>
  <li class="li2"></li>
  <li>3.Shipping Method</li>
  <li class="li2"></li>
  <li class="li1L"></li>
  <li class="li1">4.Payment and Confirmation</li>
  <li class="li1R"></li>
</ol>
<?if(count($this->orderArray)>0):?>
<form id="paymentForm" action="pay-paypal" method="post">
  <div class="YourOrders"><strong>Your orders have been placed successfully.</strong>
    PO#:&nbsp;&nbsp;<?foreach($this->orderArray as $value):?><?=$value['orderid']?>&nbsp;&nbsp;<?endforeach;?></div>
  <div class="BuyContentTit"><img src="html/images/shop/Payment.gif" alt="" width="28" height="27" />Payment Confirmation</div>
  <div class="RYO4">
  	<?foreach($this->orderArray as $value2):?>
    <ul class="RYO4UL">
      <li class="li1">PO#:<?=$value2['orderid']?><input type="hidden" value="<?=$value2['orderid']?>" name="orderid[]" /></li>
      <li class="li2">Item Desscription</li>
      <li class="li3">Unit Price</li>
      <li class="li4">Quantity</li>
      <li class="li5">Price</li>
	  <?foreach(unserialize($value2['order_string']) as $value):?>
      <li class="li6"><a target="_blank" href="<?=MY_URL?>/product-detail-id-<?=$value['itemid']?>/<?=$this->encodeName($value['subject'])?>/"><?=$value['subject']?></a> ( <?=$value['pattern_name']?>,Badge Patch:<?=$value['BadgePatch']?><?if($value['buy_name_num']!=''):?>,Print:<?=$value['buy_name_num']?><?endif;?>)&nbsp;&nbsp;Plus:<?=$this->numberFormat($value['printAmounts']*2,2)?></li>
      <li class="li7">
      	<?=$this->numberFormat($value['net_price'],2)?>
      </li>
      <li class="li8"><?=$value['amounts']?></li>
      <li class="li9">USD 
      	<?if($value['buy_name_num']!=''):?>
            <?if($value['buy_BadgePatch']=='Yes'):?>
                <?=$this->numberFormat($value['amounts']*$value['net_price']+$value['printAmounts']*2+$value['amounts']*2,2)?>
    	    <?else:?>
                <?=$this->numberFormat($value['amounts']*$value['net_price']+$value['printAmounts']*2,2)?>
    	    <?endif;?>

      	<?else:?>
            <?if($value['buy_BadgePatch']=='Yes'):?>
                <?=$this->numberFormat($value['amounts']*$value['net_price']+$value['amounts']*2,2)?>
    	    <?else:?>
                <?=$this->numberFormat($value['amounts']*$value['net_price'],2)?>
    	    <?endif;?>
    	<?endif;?>
      </li>
	  <?endforeach;?>
<?if($this->LagnappeArray[$value2['orderid']][0]):?>
      <li class="li6"><strong>gift:</strong> <?=$this->LagnappeArray[$value2['orderid']][0]["ltitle"]?></li>
      <li class="li7">
      	<?=$this->numberFormat($this->LagnappeArray[$value2['orderid']][0]["price"],2)?>
      </li>
      <li class="li8">1</li>
      <li class="li9">USD
      	<?=$this->numberFormat($this->LagnappeArray[$value2['orderid']][0]["price"],2)?>
      </li>
<?endif;?>

      <li class="li10">
<strong><a onclick="return confirmCancel();" href="product-cancelorder?orderid=<?=$value2['orderid']?>">Cancel this order</a></strong>
      </li>
      <li class="li11">
Subtotal: USD <?=$this->numberFormat($value2['money'],2)?>$<br /><br />
Shipping Cost: USD <?=$this->numberFormat($value2['yunfeiprice'],2)?>$<br /><br />
Order Total: <span class="strongSpan" id="wholesaleDiscount">USD <?=$this->numberFormat($value2['money'],2)?></span><br />
      </li>
    </ul>
	<?endforeach;?>
    <ul class="RYO4UL" id="couponsUl">
      <li class="li12">&nbsp;</li>
      <li class="li13">&nbsp;</li>
      <li class="li14">PO#:&nbsp;<?foreach($this->orderArray as $value):?><?=$value['orderid']?>&nbsp;&nbsp;<?endforeach;?></li>
      <li class="li15">You Saved: <span class="strongSpan" id="wholesaleSaved">USD <?=$this->numberFormat($this->conpon,2)?></span></li>
      <li class="li16">Total: <span class="strongSpan" id="wholesaleTotal">USD <?=$this->numberFormat($this->total-$this->conpon,2)?></span></li>
    </ul>
	<div style="border:1px #cccccc dashed;padding:10px;width:300px;">
      <div>Coupon</div><br />
	  <div>You have $<?=$this->memberArray[0]['my_coupon']?> coupons</div><br />
	  <div>I use $<input name="my_coupon" type="text" /> coupons</div><br />
    </div>
	<br />
    <ul class="RYO4UL" id="RYO4ULEnd">
      <li class="li17">Pament Information</li>
      <li class="li18">Please select method of payment:</li>
      <li class="li19">
        <div><input name="paymentMethod" onclick="payment.changeToPaypal()" type="radio" value="paypal" id="select2" /><label for="select2">Paypal</label>&nbsp;&nbsp;<span style="color:red">Charging fee: $<?=$this->total*(PAYPAL_RATE-1)?></span>&nbsp;&nbsp;<img src="html/images/logo3.gif" /></div>
      </li>
      <li class="li19">
        <div><input name="paymentMethod" onclick="payment.changeToWest()" type="radio" value="western" id="select4" /><label for="select4">Western Union</label>&nbsp;&nbsp;<img src="html/images/logo4.gif" /></div>
      </li>
	  <li class="li19">
        <div><input name="paymentMethod" onclick="payment.changeToTT()" type="radio" value="tt" id="select5" /><label for="select5">T/T&nbsp;&nbsp;TT Payment</label></div>
      </li>
      <li class="li20">Please note that it will take approximately 1 business day to confirm your payment. Before that,your order status will remain "Awaiting Payment".</li>
    </ul>
  </div>
  <div class="BuyContentEnd">
    <a href="buyer">Pay Later</a>
	<input type="hidden" value="<?=$this->total?>" name="total" />
	<input type="hidden" value="1" name="discount" />
	<input type="hidden" value="<?foreach($this->orderArray as $value2):?>#PO<?=$value2['orderid']?>,<?endforeach;?>" name="item_name" />
	<input type="image" onclick="dopay();" src="html/images/shop/PayMyOrder.gif" name="submit" > 
  </div>
</form>
<?else:?>
	<?=$this->getMsg('No orders temporarily!');?>
<?endif;?>
<script>

function confirmCancel(){
	if(confirm("Sure to cancel this order?")){
		return true;
	}else{
		return false;
	}
}


function dopay(){
	var hasSelect=false;
	$('input[name="paymentMethod"]').each(
		function(){
			if($(this).attr('checked')==true){
				hasSelect=true;
			}
		}
	);
	if(!hasSelect){
		alert('Please select a payment method!');
		$('#paymentForm').submit(
			function(){
				return false;
			}
		);
	}else{
		$('#paymentForm')[0].submit();
		showMsg('<img src=\'html/images/loading.gif\' />');
	}
}

var payment={
	changeToPaypal:function(){
		$('#paymentForm').attr('action','pay-paypal');
	},
	changeToWest:function(){
		$('#paymentForm').attr('action','pay-west');
	},
	changeToTT:function(){
		$('#paymentForm').attr('action','pay-tt');
	}
}

</script>